package 题目集.贪心.排序模拟;

import java.util.Arrays;
import java.util.Scanner;

public class 稍大的串 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] chars = sc.nextLine().toCharArray();
        int j=chars.length-1;
        int i = chars.length - 2;
        for (; i >= 0; i--) {
            if (chars[j] > chars[i]) {
                char temp = chars[j];
                chars[j] = chars[i];
                chars[i] = temp;
                break;
            }
        }
        Arrays.sort(chars, i+1, chars.length);
        System.out.println(new String(chars));
    }
}
